<?php
$uid1 = $_POST['uid1'];//用户
$uid2 = $_POST['uid2'];//关注对象
include ("conn.php");
$sql = "SELECT * FROM attention WHERE uid1=".(int)$uid1." AND uid2=".(int)$uid2;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
	//已经关注了，给它们取消关注
	//DELETE FROM Person WHERE LastName = 'Wilson' 
	$sql = "DELETE FROM attention WHERE uid1 = ".$uid1." AND uid2 = ".$uid2;
	$result = $conn->query($sql);
	exit('{"code":"已取消关注"}');
}
//它们关注上
//INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')
$sql = "INSERT INTO attention (uid1, uid2)
		VALUES (".$uid1.", ".$uid2.")";
$result = $conn->query($sql);
echo '{"code":"已添加关注"}';
?>